$(function () {
    $('#exchangeActive').click(function () {
        if ($('#commodity_address').val()=='' || $('#commodity_address').val() == null){
            toastr.warning("地址不能为空")
            return null
        }
        var resultJson={};
        resultJson.commodity_id=$('#commodity_id').val();  //触发器更改商品库存用到
        resultJson.commodity_pic=$('#commodity_pic').val();
        resultJson.commodity_address=$('#commodity_address').val();
        resultJson.usedIntegral= $('#commodity_integral').val();
        $.ajax({
            url : ctx+"homeHigh/integralEx",
            type:"post",
            data : resultJson,
            dataType : "json",
            success :function (data) {
                if(data.msg =='兑换成功'){
                    $('#exchangeModal').modal('hide')
                    toastr.success(data.msg+",待收货");
                    setTimeout(function () {
                        window.location.reload();
                    },1000)
                }
                else {
                    toastr.error(data)
                }
            }
        })

    })

})

/*鼠标移入事件操作*/
function removeClassType($this) {
    $($this).attr("title",$this.innerText);
}

/*兑换*/
function exchange(id,pic,userIntegral,comIntegral) {
    console.info("我的积分:"+userIntegral+"---商品积分:"+comIntegral)
    if (userIntegral < comIntegral){
       /* $('#exchangeModal').modal('hide')*/
        setTimeout(function () {  /*我太聪明了吧，可是这种方式还是很蠢 动态赋予按钮模态框属性*/
            $('#exchangeModal').modal('hide');
        },500)
        toastr.warning("积分不足");
        return null
    }
    $('#commodity_integral').val(comIntegral);
    $('#commodity_id').val(id);
    $('#commodity_pic').val(pic);
}

